﻿/**
 * 通用js方法封装处理
 * Copyright (c) 2019 sinosoft
import {MessageBox } from 'element-ui'

const baseURL = process.env.VUE_APP_BASE_API

// 日期格式化
export function parseTime(time, pattern) {
	if (arguments.length === 0 || !time) {
		return null
	}
	const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
	let date
	if (typeof time === 'object') {
		date = time
	} else {
		if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
			time = parseInt(time)
		} else if (typeof time === 'string') {
			time = time.replace(new RegExp(/-/gm), '/');
		}
		if ((typeof time === 'number') && (time.toString().length === 10)) {
			time = time * 1000
		}
		date = new Date(time)
	}
	const formatObj = {
		y: date.getFullYear(),
		m: date.getMonth() + 1,
		d: date.getDate(),
		h: date.getHours(),
		i: date.getMinutes(),
		s: date.getSeconds(),
		a: date.getDay()
	}
	const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
		let value = formatObj[key]
		// Note: getDay() returns 0 on Sunday
		if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] }
		if (result.length > 0 && value < 10) {
			value = '0' + value
		}
		return value || 0
	})
	return time_str
}

// 表单重置
export function resetForm(refName) {
	if (this.$refs[refName]) {
		this.$refs[refName].resetFields();
	}
}

// 添加日期范围
export function addDateRange(params, dateRange, propName) {
	var search = params;
	search.params = {};
	if (null != dateRange && '' != dateRange) {
		if (typeof(propName) === "undefined") {
			search.params["beginTime"] = dateRange[0];
			search.params["endTime"] = dateRange[1];
		} else {
			search.params["begin" + propName] = dateRange[0];
			search.params["end" + propName] = dateRange[1];
		}
	}
	return search;
}

// 回显数据字典
export function selectDictLabel(datas, value) {
	var actions = [];
	Object.keys(datas).some((key) => {
		if (datas[key].dictValue == ('' + value)) {
			actions.push(datas[key].dictLabel);
			return true;
		}
	})
	return actions.join('');
}

// 回显数据字典（字符串数组）
export function selectDictLabels(datas, value, separator) {
	var actions = [];
	var currentSeparator = undefined === separator ? "," : separator;
	var temp = value.split(currentSeparator);
	Object.keys(value.split(currentSeparator)).some((val) => {
        Object.keys(datas).some((key) => {
            if (datas[key].dictValue == ('' + temp[val])) {
				actions.push(datas[key].dictLabel + currentSeparator);
			}
		})
	})
	return actions.join('').substring(0, actions.join('').length - 1);
}

// 通用下载方法
export function download(fileName) {
	window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true;
}

// 字符串格式化(%s )
export function sprintf(str) {
	var args = arguments, flag = true, i = 1;
	str = str.replace(/%s/g, function () {
		var arg = args[i++];
		if (typeof arg === 'undefined') {
			flag = false;
			return '';
		}
		return arg;
	});
	return flag ? str : '';
}

// 转换字符串，undefined,null等转化为""
export function praseStrEmpty(str) {
	if (!str || str == "undefined" || str == "null") {
		return "";
	}
	return str;
}

/**
 * 构造树型结构数据
 * @param {*} data 数据源
 * @param {*} id id字段 默认 'id'
 * @param {*} parentId 父节点字段 默认 'parentId'
 * @param {*} children 孩子节点字段 默认 'children'
 */
export function handleTree(data, id, parentId, children) {
	let config = {
		id: id || 'id',
		parentId: parentId || 'parentId',
		childrenList: children || 'children'
	};

	var childrenListMap = {};
	var nodeIds = {};
	var tree = [];

	for (let d of data) {
		let parentId = d[config.parentId];
		if (childrenListMap[parentId] == null) {
			childrenListMap[parentId] = [];
		}
		nodeIds[d[config.id]] = d;
		childrenListMap[parentId].push(d);
	}

	for (let d of data) {
		let parentId = d[config.parentId];
		if (nodeIds[parentId] == null) {
			tree.push(d);
		}
	}

	for (let t of tree) {
		adaptToChildrenList(t);
	}

	function adaptToChildrenList(o) {
		if (childrenListMap[o[config.id]] !== null) {
			o[config.childrenList] = childrenListMap[o[config.id]];
		}
		if (o[config.childrenList]) {
			for (let c of o[config.childrenList]) {
				adaptToChildrenList(c);
			}
		}
	}
	return tree;
}

/**
* 参数处理
* @param {*} params  参数
*/
export function tansParams(params) {
	let result = ''
	Object.keys(params).forEach((key) => {
		if (!Object.is(params[key], undefined) && !Object.is(params[key], null) && !Object.is(JSON.stringify(params[key]), '{}')) {
			result += encodeURIComponent(key) + '=' + encodeURIComponent(params[key]) + '&'
		}
	})
	return result
}


// 接口参数格式转化：JSON格式的数组转化为字符串（type:'1,2,3')
export function jsonArrayToStr(param) {
  const str = JSON.stringify(param).replace('[','').replace(']','').replace(/\s*/g,'')
  return str
}
/**
* 页面增加水印
* @param {*} settings  设置信息
*/
export function watermark(settings) {
	// debugger;
	//默认设置
	var defaultSettings={
		watermark_txt:"text",
		watermark_x:20,//水印起始位置x轴坐标
       watermark_y:50,//水印起始位置Y轴坐标
       watermark_rows:9,//水印行数
		watermark_cols:10,//水印列数
       watermark_x_space:10,//水印x轴间隔
       watermark_y_space:30,//水印y轴间隔
		// watermark_color:'#aaa',//水印字体颜色
		watermark_color:'#B6B5B5',//水印字体颜色
       watermark_alpha:0.2,//水印透明度
		watermark_fontsize:'15px',//水印字体大小
		watermark_font:'微软雅黑',//水印字体
       watermark_width:250,//水印宽度
		watermark_height:80,//水印长度
		watermark_angle:15//水印倾斜度数
	};
	//采用配置项替换默认值，作用类似jquery.extend
	if(arguments.length===1&&typeof arguments[0] ==="object" )
	{
		var src=arguments[0]||{};
		for(var keyS in src)
		{
			if(src[keyS]&&defaultSettings[keyS]&&src[keyS]===defaultSettings[keyS])
				continue;
			else if(src[keyS])
				defaultSettings[keyS]=src[keyS];
		}
	}
   
	var oTemp = document.createDocumentFragment();
   
	//获取页面最大宽度
	var page_width = Math.max(document.body.scrollWidth,document.body.clientWidth);
	var cutWidth = page_width*0.0150;
	var page_width=page_width-cutWidth;
	//获取页面最大高度
	var page_height = Math.max(document.body.scrollHeight,document.body.clientHeight)+650;
	// var page_height = document.body.scrollHeight+document.body.scrollTop;
	//如果将水印列数设置为0，或水印列数设置过大，超过页面最大宽度，则重新计算水印列数和水印x轴间隔
	if (defaultSettings.watermark_cols == 0 || (parseInt(defaultSettings.watermark_x + defaultSettings.watermark_width *defaultSettings.watermark_cols + defaultSettings.watermark_x_space * (defaultSettings.watermark_cols - 1)) > page_width)) {
		defaultSettings.watermark_cols = parseInt((page_width-defaultSettings.watermark_x+defaultSettings.watermark_x_space) / (defaultSettings.watermark_width + defaultSettings.watermark_x_space) - 1);
		defaultSettings.watermark_x_space = parseInt((page_width - defaultSettings.watermark_x - defaultSettings.watermark_width * defaultSettings.watermark_cols) / (defaultSettings.watermark_cols - 1) - 10);
	}
	//如果将水印行数设置为0，或水印行数设置过大，超过页面最大长度，则重新计算水印行数和水印y轴间隔
	if (defaultSettings.watermark_rows == 0 || (parseInt(defaultSettings.watermark_y + defaultSettings.watermark_height * defaultSettings.watermark_rows + defaultSettings.watermark_y_space * (defaultSettings.watermark_rows - 1)) > page_height)) {
		defaultSettings.watermark_rows = parseInt((defaultSettings.watermark_y_space + page_height - defaultSettings.watermark_y) / (defaultSettings.watermark_height + defaultSettings.watermark_y_space));
		defaultSettings.watermark_y_space = parseInt(((page_height - defaultSettings.watermark_y) - defaultSettings.watermark_height * defaultSettings.watermark_rows) / (defaultSettings.watermark_rows - 1));
	}
	var x;
	var y;
	for (var i = 0; i < defaultSettings.watermark_rows; i++) {
		y = defaultSettings.watermark_y + (defaultSettings.watermark_y_space + defaultSettings.watermark_height) * i;
		for (var j = 0; j < defaultSettings.watermark_cols; j++) {
			x = defaultSettings.watermark_x + (defaultSettings.watermark_width + defaultSettings.watermark_x_space) * j;
   
			var mask_div = document.createElement('div');
			mask_div.id = 'mask_div' + i + j;
			mask_div.className = 'mask_div';
			mask_div.appendChild(document.createTextNode(defaultSettings.watermark_txt));
			//设置水印div倾斜显示
			mask_div.style.webkitTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
			mask_div.style.MozTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
			mask_div.style.msTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
			mask_div.style.OTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
			mask_div.style.transform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
			mask_div.style.visibility = "";
			mask_div.style.position = "absolute";
			mask_div.style.left = x + 'px';
			mask_div.style.top = y + 'px';
			mask_div.style.overflow = "hidden";
			mask_div.style.zIndex = "9999";
			mask_div.style.pointerEvents='none';//pointer-events:none  让水印不遮挡页面的点击事件
			//mask_div.style.border="solid #eee 1px";
			mask_div.style.opacity = defaultSettings.watermark_alpha;
			mask_div.style.fontSize = defaultSettings.watermark_fontsize;
			mask_div.style.fontFamily = defaultSettings.watermark_font;
			mask_div.style.color = defaultSettings.watermark_color;
			mask_div.style.textAlign = "center";
			mask_div.style.width = defaultSettings.watermark_width + 'px';
			mask_div.style.height = defaultSettings.watermark_height + 'px';
			mask_div.style.display = "block";
			oTemp.appendChild(mask_div);
		};
	};
	document.body.appendChild(oTemp);
  }

// 手机号、银行卡、身份证'*'替换type为1，表示传递过来的data为电话号码，type为2时代表传递过来的data为银行卡号码
//type为3时代表传递过来的data为身份证号码
export function num_replace(data,type){
	var number = "" + data;
	if(type==1){
		var number1 =number.replace(number.substring(3,7), "****")
		return number1
	} else if(type==2){
		return '****' + number.substring(number.length-4);
	} else {
		return number.substring(0,3) + '****' + number.substring(number.length-3)
	}
}

//日期控件列表覆盖问题---mc
// export function elDatePickerTopStyle(cssStyle){
//     if(cssStyle=='top'){
//         $('.el-picker-panel').addClass('elDatePickerTopStyle');
//     } else {
//         $('.el-picker-panel').removeClass('elDatePickerTopStyle');
//     }
// }

// 当当前页只剩下一条时，删除页数可以自减
export function pageNumber_reduce(number,total,pageSize){
	if(number == '1' && total > pageSize){
        return true;
    } else {
        return false;
    }
}

// el-table选中背景色
export function tableRowClassName({ row }) {
	return row.className;
}

// 下拉框根据码值获取label
export const getLabelByDictValue=(option,code)=>{
   return option.find(item=>item.dictValue===code)?option.find(item=>item.dictValue===code).dictLabel:''
}
 
// 获取机构的公共方法
export function obtainManageCom(val) {
  // 获取一级管理机构
  if(val == 'manageList'){
    return JSON.parse(localStorage.getItem('manageList'))
  }else if (val == 'manageTwoList'){  // 获取二级管理机构
    return JSON.parse(localStorage.getItem('manageTwoList'))
  }else if (val == 'manageTwoAndThreeList'){ // 获取二三级管理机构
    return JSON.parse(localStorage.getItem('manageTwoAndThreeList'))
  }
}

// 选择提示功能
export function choosePromptInform(msg,fn,caBack) {
    MessageBox.confirm(msg, '提示', {
		confirmButtonText: '确定',
        cancelButtonText: '取消',
        showClose:false,
	}).then(()=>{
        if(typeof fn == 'function'){
            fn();
        }
    }).catch(e=>{
        if(typeof caBack == 'function'){
            caBack();
        }
    })
}

// 提示信息弹层样式-1001
// 规则类（弹窗消息提示，手动关闭）
// 1001：规则类-阻断提示（点击确认/叉号关闭弹层，无特殊处理，多条以 # 号分隔）-承保、保全、核保
export function tipInfo_1001(msg,fn,caBack) {
    // var newMsg = String(msg).replace(/#/g,"<br/>");
    // this.$alert(newMsg, '提示', {
    //     confirmButtonText: '确定',
    //     dangerouslyUseHTMLString:true
    // });
	this.$layer.closeAll()
    let arr= msg.split('#');
	if(arr.length>1){
		let newMsg='';
		for(let i=0;i<arr.length;i++){
			if(i==arr.length-1){
				newMsg=newMsg+(i+1)+'.'+arr[i]
			}else{
				newMsg=newMsg+(i+1)+'.'+arr[i]+'</br>'
			}
		}
		msg=newMsg
	}
	this.$layer.open({
		title: '提示',
		content: msg,
		btn: ['确定', '取消'],
		shade: false,//是否显示遮罩
		shadeClose: false,//点击遮罩是否关闭
		area: ['30%', '250px'], //宽高
		yes: function(index,layero){
			if(typeof fn == 'function'){
				fn();
			}
			this.layer.close(index);
		},
		cancel: function(index){
			if(typeof caBack == 'function'){
				caBack();
			}
			this.layer.close(index);
		},
	});
}

// 提示信息弹层样式-1002
// 规则类（弹窗消息提示，手动关闭）
// 1002：规则类-阻断+非阻断、非阻断 提示（点击确认/叉号关闭弹层，无特殊处理，多条以 # 号分隔）-承保、保全、核保
export function tipInfo_1002(msg,fn,caBack) {
	this.$layer.closeAll()
    let arr= msg.split('#');
	if(arr.length>1){
		let newMsg='';
		for(let i=0;i<arr.length;i++){
			if(i==arr.length-1){
				newMsg=newMsg+(i+1)+'.'+arr[i]
			}else{
				newMsg=newMsg+(i+1)+'.'+arr[i]+'</br>'
			}
		}
		msg=newMsg
	}
	this.$layer.open({
		title: '提示',
		content: msg,
		btn: ['确定', '取消'],
		shade: false,//是否显示遮罩
		shadeClose: false,//点击遮罩是否关闭
		area: ['30%', '250px'], //宽高
		yes: function(index,layero){
			if(typeof fn == 'function'){
				fn();
			}
			this.layer.close(index);
		},
		cancel: function(index){
			if(typeof caBack == 'function'){
				caBack();
			}
			this.layer.close(index);
		},
	});
	// MessageBox.confirm(msg, '提示', {
	// 	confirmButtonText: '确定',
    //     cancelButtonText: '取消',
    //     showClose:false,
	// }).then(()=>{
    //     if(typeof fn == 'function'){
    //         fn();
    //     }
    // }).catch(e=>{
    //     if(typeof caBack == 'function'){
    //         caBack();
    //     }
    // })
}

export function alert(msg,fn){
	let arr= msg.split('#');
	if(arr.length>1){
		let newMsg='';
		for(let i=0;i<arr.length;i++){
			if(i==arr.length-1){
				newMsg=newMsg+(i+1)+'.'+arr[i]
			}else{
				newMsg=newMsg+(i+1)+'.'+arr[i]+'\n'
			}
		}
		msg=newMsg
	}
	MessageBox.alert(msg, '提示', {
		confirmButtonText: '确定',
		callback: fn
	})
}

// 获取指定日期几岁的前一天,data指定日期，year几岁
export function getYesterday (SystemDate,year=0) {
    var date = new Date(SystemDate); //获取当前时间
    const trueDate = date.getDate();    //获取输入日期的 日
    const trueMonth = date.getMonth()+1;    //获取输入日期的 月  ps:+1是因为月是从0开始的，所以真实的月份需要+1
    const trueYear = date.getFullYear() + year;    //获取输入日期的 年
    var dateString ='';     //定义一个字符串，用户存放字符串形式的日期
    if(trueDate!==1){       //如果指定日期的‘日’不是1号，年、月不变，日减一即可
        dateString = trueYear+'-'+replaceMonth(trueMonth)+'-'+ replaceMonth(trueDate-1);
    }else if(trueMonth==5||trueMonth==7||trueMonth==10||trueMonth==12){
        //如果‘日’是1号，就判断指定日期所在月分，5,7,10,12这几个月的前一个月都是30天，只需月减一，日设置为30即可
        dateString = trueYear+'-'+replaceMonth(trueMonth-1)+'-'+ 30;
    }else if(trueMonth==2||trueMonth==4||trueMonth==6||trueMonth==8||trueMonth==9||trueMonth==11){
        //如果是2,4,6,8,9,11这几个月的前一个月是31天，只需月减一，日设置为31即可
        dateString = trueYear+'-'+replaceMonth(trueMonth-1)+'-'+ 31;
    }else if(trueMonth==1){
        //如果是一月一号的话，年减一，月日设置为12/31
        dateString = (trueYear-1)+'-'+12+'-'+ 31;
    }else if(trueMonth==3){
        //如果是三月一号的话，就要判断年份是否闰年
        if(trueYear%4==0&&trueYear%100!=0||trueYear%400==0){
            dateString = trueYear+'-'+'02'+'-'+29
        }else{
            dateString = trueYear+'-'+'02'+'-'+28
        }
    }
    return dateString;
}
// 后端返回1001、1002公用的alert回调方法
export function confirm(msg,fn, caBack){
	let arr= msg.split('#');
	if(arr.length>1){
		let newMsg='';
		for(let i=0;i<arr.length;i++){
			if(i==arr.length-1){
				newMsg=newMsg+(i+1)+'.'+arr[i]
			}else{
				newMsg=newMsg+(i+1)+'.'+arr[i]+'\n'
    }
}
		msg=newMsg
    }
	MessageBox.confirm(msg, '提示', {
		confirmButtonText: '确定',
        cancelButtonText: '取消',
        showClose:false,
        type: 'warning'
	}).then(()=>{
        fn()
    }).catch(e=>{
		caBack()
    })
}
export function getImageTypeList(type){
    // 新单录入、
    if(type == 'XDLR'){
        return [
            { subType: "1001" },
            { subType: "1003" },
            { subType: "1005" },
            { subType: "1050" },
            { subType: "1098" },
            { subType: "1102" },
            { subType: "1131" },
            { subType: "1123" },
            { subType: "1116" },
            { subType: "1127" },
            { subType: "1126" },
            { subType: "1107" },
            { subType: "1108" },
            { subType: "1109" },
            { subType: "1207" },
            { subType: "1120" },
            { subType: "1114" },
            { subType: "1133" },
            { subType: "1101" },
            { subType: "1115" },
            { subType: "1052" },
            { subType: "1135" },
        ]
    }else if (type == 'XDFH'){ // 新单复核
        return [
            { subType: "1001" },
            { subType: "1003" },
            { subType: "1005" },
            { subType: "1050" },
            { subType: "1098" },
            { subType: "1102" },
            { subType: "1131" },
            { subType: "1123" },
            { subType: "1116" },
            { subType: "1127" },
            { subType: "1126" },
            { subType: "1107" },
            { subType: "1108" },
            { subType: "1124" },
            { subType: "1109" },
            { subType: "1207" },
            { subType: "1120" },
            { subType: "1114" },
            { subType: "1133" },
            { subType: "1101" },
            { subType: "1115" },
            { subType: "1052" },
            { subType: "1135" },
        ]
    }else if(type == 'BDWTXG' ){ // 保单问题修改
        return [
            { subType: "1001" },
            { subType: "1003" },
            { subType: "1005" },
            { subType: "1050" },
            { subType: "1098" },
            { subType: "1102" },
            { subType: "1131" },
            { subType: "1123" },
            { subType: "1116" },
            { subType: "1127" },
            { subType: "1126" },
            { subType: "1107" },
            { subType: "1108" },
            { subType: "1124" },
            { subType: "1109" },
            { subType: "1207" },
            { subType: "1120" },
            { subType: "1114" },
            { subType: "1133" },
            { subType: "1101" },
            { subType: "1115" },
            { subType: "1052" },
        ]
    }else if(type == 'TBDMX' || type == 'YXZJ' || type == 'XDZJCJ'){// 投保单查询-投保单明细-合同信息、影像质检-投保单影像-合同信息、新单质检抽检
        return [
            { subType: "1001" },
            { subType: "1003" },
            { subType: "1005" },
            { subType: "1050" },
            { subType: "1098" },
            { subType: "1102" },
            { subType: "1131" },
            { subType: "1123" },
            { subType: "1116" },
            { subType: "1127" },
            { subType: "1126" },
            { subType: "1107" },
            { subType: "1108" },
            { subType: "1124" },
            { subType: "1109" },
            { subType: "1207" },
            { subType: "1120" },
            { subType: "1114" },
            { subType: "1133" },
            { subType: "1101" },
            { subType: "1115" },
            { subType: "1052" },
            { subType: "1103" },
            { subType: "1104" },
            { subType: "1028" },
            { subType: "1045" },
            { subType: "1023" },
            { subType: "1020" },
            { subType: "1066" },
            { subType: "1064" },
            { subType: "1070" },
            { subType: "1071" },
            { subType: "1053" },
            { subType: "1055" },
            { subType: "1135" },
        ]
    }else if(type == 'HZHX' || type == 'HZZJBHG' || type == 'XSHZ'){ // 回执回销、回执质检不合格、 影像质检-线上回执
        return [
            { subType: "1055" },
        ]
    }else if(type == 'HEALTH'){ // 函件回销-体检函
        return [
            { subType: "1028" },
        ]
    }else if(type == 'DEEDNOTICE'){ // 函件回销-契调函
        return [
            { subType: "1045" },
        ]
    }else if(type == 'WORK'){ // 函件回销-新契约作业函
        return [
            { subType: "1066" },
            { subType: "1103" },
            { subType: "1104" },
            { subType: "1131" },
            { subType: "1064" },
        ]
    }else if(type == 'LOSE'){ // 函件回销-划账失败函划账失败函
        return [
{ subType: "1019" },
            { subType: "1020" },
        ]
    }else if(type == 'HXFH' || type == 'QYHJCX'){ // 契调函回销复核-生调函回销复核操作、契约函件查询-契约函件查询子页面 
        return [
            { subType: "1045" },
        ]
    }else if (type == 'TBDYX'){ // 投保单影像-相似客户
        return [
            { subType: "1101" },
            { subType: "1103" },
            { subType: "1005" },
            { subType: "1050" },
            { subType: "1098" },
        ]
    }
}
export function replaceMonth(month){
    let trueMonth = month;
    if(month < '10'){
        trueMonth = '0' + month;
    }
    return trueMonth
}

/**
 * 获取当前年月日
 */
export function formatDay() {
  var date = new Date() 
  var year = date.getFullYear()
  var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
  var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() 
  return year + '-' + month + '-' + day
}

/**
 * 获取当前时分秒
 */
export function formatTimeNew() {
  var date = new Date() 
  var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours() 
  var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() 
  var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
  return hours + ':' + minutes + ':' + seconds
}
// 获取当前时间字符串格式 例如：20200101102330 用于导出下载文件名称展示
export function currentTimeNew() {
    let date = new Date()
    var y = date.getFullYear();  
    var m = date.getMonth() + 1;  
    m = m < 10 ? '0' + m : m;  
    var d = date.getDate();  
    d = d < 10 ? ('0' + d) : d;  
    var hours = date.getHours();
    hours =hours < 10 ? ('0' + hours) : hours;
    var minutes = date.getMinutes();
    minutes = minutes < 10 ? ('0' + minutes) : minutes;
    var seconds = date.getSeconds();
    seconds = seconds < 10 ? ('0' + seconds) : seconds;
    return String(y) + String(m) + String(d)+ String(hours) + String(minutes) + String(seconds);
}

//blob所有文件下载适用
export function BlobDownLoad(param,data) {
	const content = data
	const blob = new Blob([content])
	if('msSaveOrOpenBlob' in navigator){
		window.navigator.msSaveOrOpenBlob(blob, filename)
		return;
	}
	if ('download' in document.createElement('a')) {
		const elink = document.createElement('a')
		elink.download = `client_${new Date().getTime()}.${param[1]}`
		elink.style.display = 'none'
		elink.href = URL.createObjectURL(blob)
		document.body.appendChild(elink)
		elink.click()
		URL.revokeObjectURL(elink.href)
		document.body.removeChild(elink)
	}
}
 // 影像图片放大缩小功能
 export function rollImg(e,zoom,img,mini) {
    if(mini){
        // 点击缩小处理
        var direction = 'down' 
    }else{
        var direction = e.deltaY > 0 ? 'down' : 'up'

    }
    if (direction === 'up') {
        // 滑轮向上滚动 放大
        if (zoom < 6) {
            zoom += 0.10
        }
        document.querySelector(img).style.transform = `matrix(${zoom}, 0, 0,${zoom}, 0, 0)`
    } else {
        // 滑轮向下滚动 缩小
        if (zoom > 0.3) {
            zoom -= 0.10
        }
        document.querySelector(img).style.transform = `matrix(${zoom}, 0, 0, ${zoom}, 0, 0)`
    }
    return zoom
}
// 影像图片旋转功能实现
export function Rotate(deg,i){
         if(i=='1'){
        // 顺时针旋转
        deg += 90;
        }else{
        // 逆时针旋转		
        deg -= 90;
        }
         if(deg >= 360){
             deg = 0
         }
		if(deg<0){
			deg = 360-90
		}
         document.querySelector('.imgs').style.transform = `rotate(${deg}deg)`
    return deg
}